﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Collections;

namespace PaperManager
{
    public partial class QueryForm : Form
    {
        public MainForm paForm;
        public QueryForm()
        {
            InitializeComponent();
            DataGridViewTextBoxColumn colTitle = new DataGridViewTextBoxColumn();
            colTitle.HeaderText = "论文名";
            grdPaper.Columns.Add(colTitle);
            DataGridViewTextBoxColumn colAuthor = new DataGridViewTextBoxColumn();
            colAuthor.HeaderText = "作者";
            grdPaper.Columns.Add(colAuthor);
            DataGridViewTextBoxColumn colKeyWords = new DataGridViewTextBoxColumn();
            colKeyWords.HeaderText = "关键词";
            grdPaper.Columns.Add(colKeyWords);
            DataGridViewTextBoxColumn colAbstract = new DataGridViewTextBoxColumn();
            colAbstract.HeaderText = "摘要";
            grdPaper.Columns.Add(colAbstract);
        }

        private void btnSearch_Click(object sender, EventArgs e)
        {
            string queryS;
            queryS = tbxSearch.Text;
            //定义临时arraylist
            ArrayList tmpAl;
            tmpAl = paForm.paperAL.query(queryS);
            for (int i = 0; i < tmpAl.Count;i++ )
            {
                MyContainer.Itm tmp;
                tmp = (MyContainer.Itm)tmpAl[i];
                int curR = this.grdPaper.Rows.Count-1;
                DataGridViewTextBoxCell cell0 = new DataGridViewTextBoxCell();
                cell0.Value = tmp.Title;
                this.grdPaper[0, curR] = cell0;
                DataGridViewTextBoxCell cell1 = new DataGridViewTextBoxCell();
                cell1.Value = tmp.Author;
                this.grdPaper[1, curR] = cell1;
                DataGridViewTextBoxCell cell2 = new DataGridViewTextBoxCell();
                cell2.Value = tmp.KeyWords;
                this.grdPaper[2, curR] = cell2;
                DataGridViewTextBoxCell cell3 = new DataGridViewTextBoxCell();
                cell3.Value = tmp.Abstract;
                this.grdPaper[3, curR] = cell3;
            }
        }
    }
}
